package day01;

import java.util.Scanner;

/**
 * Created by MGL on 2017/4/2.
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        long sum = 0;
        for (int i = 0; i < arr.length; i++) {
            int count = 0;
            for (int j = 0; j < arr.length; j++) {
                if (j > i) {
                    if (arr[j] < arr[i]) {
                        count++;
                    }
                } else if (j < i) {
                    if (arr[j] > arr[i]) {
                        count++;
                    }
                }
            }
            sum += (count + 1) * count / 2;
        }
        System.out.println(sum);
    }
}
